home *** CD-ROM | disk | FTP | other *** search
- #ifdef __STDC__
- static char sccs_id[] = "@(#) strdup.c 1.0 "__DATE__" HJR";
- #else
- static char sccs_id[] = "@(#) strdup.c 1.0 8/11/91 HJR";
- #endif
-
- /* strdup.c (c) Copyright 1990 H.Rogers */
-
- #ifndef __STDC__
- #include "sys/types.h"
- #endif
-
- #include <string.h>
- #ifdef ARCH
- #include "sys/unix.h"
- #else
- #include <stdlib.h>
- #endif
-
- #ifdef __STDC__
- char *strdup(register const char *s1)
- #else
- char *strdup(s)
- register const char *s1;
- #endif
- {
- #ifdef ARCH
- return(__permstr(s1));
- #else
- register int i = strlen(s1) + 1;
- register char *s2;
-
- if (!(s2 = malloc(i))) return(0);
- memcpy(s2,s1,i);
- return(s2);
- #endif
- }
-